import java.util.Scanner;
import java.lang.String;

public class Complex {
    double shibu;
    double xubu;

    public Complex(double shibu, double xubu) {
        this.shibu = shibu;
        this.xubu = xubu;
    }

    public static double getShibu(double shibu) {
        return shibu;
    }

    public static double getXubu(double xubu) {
        return xubu;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof Complex)) {
            return false;
        }
        Complex complex = (Complex) obj;
        if (complex.shibu != ((Complex) obj).shibu) {
            return false;
        }
        if (complex.xubu != ((Complex) obj).xubu) {
            return false;
        }

        return true;
    }

    Complex ComplexAdd(Complex a) {
        double shibu2 = shibu + a.shibu;
        double xubu2 = xubu + a.xubu;
        return new Complex(shibu2, xubu2);
    }

    Complex ComplexSub(Complex b) {
        double shibu2 = shibu - b.shibu;
        double xubu2 = xubu - b.xubu;
        return new Complex(shibu2, xubu2);
    }

    Complex ComplexMulti(Complex c) {
        double shibu2 = (shibu * c.shibu) - (xubu * c.xubu);
        double xubu2 = (xubu * c.xubu) + (xubu * c.shibu);
        return new Complex(shibu2, xubu2);
    }

    Complex ComplexDiv(Complex d) {
        double shibu2 = (shibu * d.xubu + xubu * d.shibu) / (d.xubu * d.xubu + d.shibu * d.shibu);
        double xubu2 = (xubu * d.xubu + shibu * d.shibu) / (d.shibu * d.shibu + d.xubu * d.xubu);
        return new Complex(shibu2, xubu2);
    }

    @Override
    public String toString() {
        String s = "";
        if (xubu > 0) {
            s = shibu + "+" + xubu + "i";
        }
        if (xubu < 0) {
            s = shibu + " "+xubu + "i";
        }
        if (xubu == 0) {
            s = "" + shibu;
        }
        return s;
    }
}
